package com.example.mansystem.Activiti;

import com.example.mansystem.entity.InstrumentDO;
import com.example.mansystem.entity.InstrumentExamineDO;
import com.example.mansystem.mapper.DegreeMapper;
import com.example.mansystem.mapper.InstrumentExamineMapper;
import com.example.mansystem.mapper.InstrumentMapper;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Component("DegreeServiceTask")
public class DegreeServiceTask implements Serializable, JavaDelegate {
    private static InstrumentExamineMapper instrumentExamineMapper;
    private static InstrumentMapper instrumentMapper;
    private static DegreeMapper degreeMapper;

    private static final long serialVersionUID = 1L;

    @Autowired
    public  void setInstrumentExamineMapper(InstrumentExamineMapper instrumentExamineMapper)
    {
        DegreeServiceTask.instrumentExamineMapper=instrumentExamineMapper;
    }

    @Autowired
    public  void setInstrumentMapper(InstrumentMapper instrumentMapper)
    {
        DegreeServiceTask.instrumentMapper=instrumentMapper;
    }

    @Autowired
    public  void setDegreeMapper(DegreeMapper degreeMapper)
    {
        DegreeServiceTask.degreeMapper=degreeMapper;
    }

    @Override
    public void execute(DelegateExecution execution) {
        int type =(int)execution.getVariable("type");
        Map<String, Object> map = new HashMap<>();
        if(type==3)
        {
            int lel=degreeMapper.selectById(3).getLel();
            map.put("lel",lel);
            execution.setVariablesLocal(map);
        }
        else if(type==2)
        {
            int lel=degreeMapper.selectById(2).getLel();
            map.put("lel",lel);
            execution.setVariablesLocal(map);
        }

    }
}
